package com.javaGame.role;

import com.javaGame.frame.MainFrame;
import com.javaGame.role.enemy.EnemyRole;

import java.awt.*;

/**
 * 女孩子弹类
 */
public class GirlBullet extends BaseRole{
    /**子弹图片*/
    public static Image girlBulletImg;
    public GirlBullet() {
        super(MainFrame.girl.x+10, MainFrame.girl.y+10,
                60, 15);
        this.currentImg = girlBulletImg;
    }

    @Override
    public void move() {
        this.x += 15;

        for(int i=0;i<MainFrame.roleList.size();i++){
            BaseRole role = MainFrame.roleList.get(i);

            //判断子弹是否击中角色
            if(this.rect.intersects(role.rect)
                    && role instanceof EnemyRole){
                MainFrame.roleList.add(new ByHitBom(x,y));
                EnemyRole enemy = (EnemyRole)role;
                //怪物减少生命
                enemy.byHit(40);
                //子弹消失
                MainFrame.roleList.remove(this);
            }

        }
    }
}
